package com.jie.component.validation.config;

import com.jie.common.util.LogUtil;
import com.jie.component.validation.aspect.ValidationAspect;
import com.jie.component.validation.core.ValidationExecutor;
import com.jie.component.validation.factory.ValidatorFactory;
import com.jie.component.validation.validator.impl.NotEmptyValidator;
import com.jie.component.validation.validator.impl.PasswordValidator;
import com.jie.component.validation.validator.impl.PhoneValidator;
import org.springframework.context.annotation.Bean;

/**
 * @author jie
 * @version 1.0 2025-02-11
 */
public class ValidationAutoConfig {

    @Bean
    public NotEmptyValidator notEmptyValidator() {
        LogUtil.autoConfigLog("NotEmptyValidator");
        return new NotEmptyValidator();
    }

    @Bean
    public PhoneValidator phoneValidator() {
        LogUtil.autoConfigLog("PhoneValidator");
        return new PhoneValidator();
    }

    @Bean
    public PasswordValidator passwordValidator() {
        LogUtil.autoConfigLog("PasswordValidator");
        return new PasswordValidator();
    }

    @Bean
    public ValidatorFactory validatorFactory() {
        LogUtil.autoConfigLog("ValidatorFactory");
        return new ValidatorFactory();
    }

    @Bean
    public ValidationExecutor validationExecutor(ValidatorFactory validatorFactory) {
        LogUtil.autoConfigLog("ValidationExecutor");
        return new ValidationExecutor(validatorFactory);
    }

    @Bean
    public ValidationAspect validationAspect(ValidationExecutor validationExecutor) {
        LogUtil.autoConfigLog("ValidationAspect");
        return new ValidationAspect(validationExecutor);
    }
}
